package com.java.demo.controller;

import com.java.demo.enity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

@Controller
public class UserController2 {

    @Resource
    private User user;

    public void printUser2() {
        System.out.println("user ->" +user);//悟空
        //bean的作用域 默认是单例模式 = 此 bean 在整个框架 Spring 容器中只有一份
    }
}
